package org.example.state;

import org.example.model.FarmMachine;

public class IdleState implements MachineState {
    @Override
    public String getStateName() {
        return "闲置状态";
    }

    @Override
    public void handleEvent(FarmMachine machine, String event) {
        switch (event) {
            case "开始任务":
                machine.setState(new WorkingState());
                System.out.println(machine.getType() + "[" + machine.getId() + "] 从闲置状态切换到工作状态");
                break;
            case "检测到故障":
                machine.setState(new FaultState());
                System.out.println(machine.getType() + "[" + machine.getId() + "] 从闲置状态切换到故障状态");
                break;
        }
    }

    @Override
    public void execute(FarmMachine machine) {
        System.out.println(machine.getType() + "[" + machine.getId() + "] 处于闲置状态，等待任务");
    }
}
